package com.qfedu.controller;

import com.qfedu.entity.User;
import com.qfedu.utils.JsonUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * projectName: bankSystem
 * author: CGY
 * time: 2020/9/4 11:43
 * description:
 */
//@WebServlet("/user/query.do")
public class UserServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        HttpSession session = request.getSession();
        User loginUser = (User) session.getAttribute("loginUser");
        if ((loginUser != null)) {
            JsonUtils.wrteJsonInfo(1,loginUser.getBankCode(),response);
        }else {
            JsonUtils.wrteJsonInfo(0,null,response);
        }
    }
}
